using System.Collections.Generic;

namespace Dslfactory.wcfLanguage
{
 public partial class DataClass
 {
  /// <summary>
  /// Members 
  /// </summary>
  public abstract IEnumerable<FieldOrProperty> Members { get;}

  /// <summary>
  /// Find a member of given name
  /// </summary>
  /// <param name="name"></param>
  /// <returns></returns>
  internal FieldOrProperty FindMemberOfName(string name)
  {
   foreach (FieldOrProperty member in Members)
    if (member.Name == name)
     return member;
   return null;
  }

  /// <summary>
  /// Create a member of the right type (depending on deriving class)
  /// </summary>
  /// <param name="store"></param>
  /// <param name="fullTypeName"></param>
  /// <returns></returns>
  internal abstract FieldOrProperty CreateMember(string fullTypeName);

  /// <summary>
  /// Show the concepts that are used by this concept
  /// </summary>
  public override void ShowUsedConcepts()
  {
   foreach (FieldOrProperty member in Members)
    if (member.Visibility == Visibility.Public)
    {
     ShowIfPossible(member.MemberFullTypeName);
     member.Representation = RepresentationKind.AsRole;
    }
  }

  protected internal override ServicesDefinition GetServicesDefinition()
  {
   return ServicesDefinition;
  }

 }
}
